home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 102 / examples / textefct.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-25  |  4.0 KB  |  87 lines

  1. /* Programmer's guide to GEM - 1986 - p.158 -listing 3.2 - CJPurcell Dec'86  */
  2. /* CTRLRC.C  -  MAIN DRIVER for draw_rc()  examples  using Mark Williams C   */
  3. /* to be tested in NDC and/or RC mode with or without GDOS for implications  */
  4. #include <portab.h>                       /* try <> and see ?? */
  5. #include <osbind.h>                       /* system constants  */
  6. #include <gemdefs.h>                      /* GEM-definition    */
  7. /* #include <obdefs.h>                    / * object definition*/
  8.  
  9. WORD contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
  10.  
  11. #define M_OFF 256
  12. #define RC_COORDS 2
  13. #define RIGHT_ALIGNED 2
  14. #define BOTTOM_ALIGNED 3
  15.  
  16. VOID main()                /* not GEMAIN as in ref. */
  17. {
  18.         WORD handle, work_in[11], work_out[57], max_w, max_h;
  19.         WORD ii;
  20.  
  21.         appl_init();                                    /* init AES for call */
  22.         handle = graf_handle( &ii,&ii,&ii,&ii );        /* get screen handle */
  23.         graf_mouse( M_OFF, NULL );                      /* hide mouse        */
  24.         v_clrwk( handle );                              /* clear workstation */
  25.  
  26.         for( ii=0; ii<11; ++ii ) work_in[ii]=1;         /* init work_in array*/
  27.         work_in[10] = RC_COORDS;                     /* using RC coordinates */
  28.         v_opnvwk( work_in, &handle, work_out );      /* open the workstation */
  29.  
  30.         max_w = work_out[0]; max_h = work_out[1];
  31.         draw_rc( handle,0,0,max_w,max_h );           /* do the examp.routine */
  32.  
  33.         vst_alignment( handle,RIGHT_ALIGNED,BOTTOM_ALIGNED,&ii,&ii );
  34.         v_gtext( handle,max_w,max_h,"Press any Key to Continue" );
  35.         evnt_keybd();                                   /* pause for viewing */
  36.         v_clsvwk( handle );                             /* close workstation */
  37.         appl_exit();                                    /* tell AES finished */
  38. }
  39.  
  40. /* Programmer's Guide to GEM - 1986 - p.199,Listing 3.13 - CJPurcell- Dec'86 */
  41. /* TEXTEFCT.C   -   ILLUSTRATE different Graphic Text Special Effects on GEM */
  42. /*  #include <portab.h>   */
  43. #define SYSTEM_FONT 1
  44. #define SWISS_FONT  2
  45. #define LEFT        0
  46. #define RIGHT       2
  47. #define BASELINE    0
  48.  
  49. BYTE *labels[] = { "Normal", "Thickened", "Light", "Skewed", "Underlined",
  50.                        "Outlined", "Shadowed" };
  51.  
  52. VOID draw_rc( handle, dx, dy, swidth, sheight )
  53.          WORD handle, dx, dy, swidth, sheight;
  54. {
  55.         WORD ii, cur_x, cur_y, incr_x, incr_y, junk, effect, resize;
  56.  
  57.         resize = 18 ;                            /* presume color system, but*/
  58.         if ( 2 == Getrez() ) resize = 36 ;       /*     BIG_LETTERS          */
  59.  
  60.  
  61.         vst_load_fonts( handle, 0 );            /* load all available fonts */
  62.         incr_x =     swidth / 40 ;
  63.         incr_y =     sheight / 8 ;
  64.         cur_x  = dx + swidth / 4 ;
  65.         cur_y  = dy + incr_y ;
  66.  
  67.         for( ii = 0, effect = 1; ii < 7; ++ii, cur_y += incr_y){
  68.                 vst_font( handle, SWISS_FONT );
  69.                 vst_point( handle, resize, &junk, &junk, &junk, &junk );
  70.                 vst_alignment( handle, LEFT, BASELINE, &junk, &junk );
  71.                 if(ii>0)                  /*  no call for normal effect  */
  72.                 {
  73.                         junk = vst_effects( handle,effect );
  74.                         effect *= 2 ;     /* shift left effects bit by 1 */
  75.                         if( effect != junk*2 )
  76.                                 continue; /* don't print lines without effect*/
  77.                  }
  78.                  v_gtext( handle, cur_x+incr_x, cur_y, "String" );
  79.                  vst_font( handle, SYSTEM_FONT);
  80.                  vst_point( handle, 14, &junk, &junk, &junk, &junk );
  81.                  vst_alignment( handle, RIGHT, BASELINE, &junk, &junk );
  82.                  v_gtext( handle, cur_x, cur_y, labels[ii] );
  83.          }
  84.          vst_effects( handle, 0 );         /* turn off special effects */
  85.          vst_unload_fonts( handle, 0 );
  86. }                                          /*      CJPurcell 08Dec'86  */
  87.